home *** CD-ROM | disk | FTP | other *** search
- Path: news.infi.net!usenet
- From: Steve Rountree <srndtree@infi.net>
- Newsgroups: comp.lang.c
- Subject: Re: Skipping ahead in a file?
- Date: Sat, 06 Apr 1996 11:55:23 -0800
- Organization: InfiNet
- Message-ID: <3166CC2B.3F3E@infi.net>
- References: <4k17td$chn@news.csus.edu>
- NNTP-Posting-Host: h-agate.dc.infi.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Ralph A Pope wrote:
- >
- > OK, basically what I want to do is take a file that's 20*(12+1)*4*4 bytes
- > long, and skip ahead 61 characters in the program several times. Then I
- > want to be able to reset the file pointer to start 20 characters away
- > from the previous starting point. I want to do this a total of 5 times.
- > Any idea of how to get this working? I can't seem to figure out
- > fseek(). I'm using MS-DOS 6.2 with DJGPP, BTW. Any help you can give me
- > would be GREATLY appreciated! :)
- >
- > -Michael P.
-
- try:
-
- FILE *info; /* open as you need to, of course. */
- long prev;
- int dist=61; /* distance to move in file. */
-
- prev=ftell(info); /* set prev to current file pointer position. */
-
- fseek(info,dist,SEEK_CUR); /* move file pointer a set distance (61) */
- prev+=20; /* assuming the 20 characters "away" is forward */
- fseek(info,prev,SEEK_SET); /* establish file pointer 20 ahead of old
- location */
-
-
- Of course you will need to do standard checking for the EOF but, I think
- this what you are "bascially" looking for. Good luck.
-
- Steve Rountree
-